﻿using Microsoft.EntityFrameworkCore;
using SunDemo.Entity;

namespace SunDemo.AppDbContext
{
    public class MyDbContext : DbContext
    {
        public DbSet<ReverseData> ReverseDatas {  get; set; }
        public MyDbContext(DbContextOptions options) : base(options)
        {
        }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //optionsBuilder.UseSqlServer("Server=localhost;Database");s
            base.OnConfiguring(optionsBuilder);
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<ReverseData>(e =>
            {
                e.ToTable("BM_ReverseData");
                e.HasKey(r=>r.RecordID);
                e.Property(r=>r.RecordID).HasColumnType("char(32)");
                e.Property(r => r.Num1).HasColumnType("int");
                e.Property(r => r.Num2).HasColumnType("int");
                e.Property(r => r.RevNum1).HasColumnType("int");
                e.Property(r => r.RevNum2).HasColumnType("int");
                e.Property(r => r.SumNum).HasColumnType("int");
                e.Property(r => r.RevSum).HasColumnType("int");
            });
            base.OnModelCreating(modelBuilder);
        }
    }
}
